home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / bin / casper-reconfigure < prev    next >
Text File  |  2008-11-11  |  1KB  |  53 lines

  1. #! /bin/sh
  2.  
  3. set -e
  4. export PATH=/usr/bin:/usr/sbin:/sbin:/bin
  5.  
  6. frontend=noninteractive
  7.  
  8. findcommandinroot() {
  9.     ROOT="$1/"
  10.     shift
  11.     while [ "$#" -ge 1 ]; do
  12.         P="$PATH"
  13.         while [ "$P" ]; do
  14.             D=${P%%:*}
  15.             P=${P#*:}
  16.             if [ "$D" = "$P" ]; then
  17.                 P=
  18.             fi
  19.             if [ -z "$D" ]; then
  20.                 D=.
  21.             fi
  22.             if [ -x "$ROOT$D/$1" ]; then
  23.                 echo "$D/$1"
  24.                 return 0
  25.             fi
  26.         done
  27.         shift
  28.     done
  29.     return 1
  30. }
  31.  
  32. runcommandinroot() {
  33.     C=$(findcommandinroot "$1" "$2")
  34.     ROOT="$1"
  35.     shift
  36.     shift
  37.     [ -n "$C" ] && chroot "$ROOT" "$C" "$@"
  38. }
  39.  
  40. root="$1"
  41. package="$2"
  42.  
  43. version=$(runcommandinroot "$root" dpkg-query -W --showformat='${Version}' "$package" 2>/dev/null) || version=""
  44.  
  45. if [ -z "$version" ]; then
  46.     echo >&2 "$0: package '$package' is not installed"
  47.     exit 0
  48. fi
  49.  
  50. runcommandinroot "$root" dpkg-reconfigure -fnoninteractive --no-reload "$package"
  51.  
  52. exit 0
  53.